<?php
class Training_AjaxController extends Zendvn_Controller_Action{
    
    public function init() {
        parent::init();
        //$this->_helper->layout->disableLayout();
        //$this->_helper->viewRenderer->setNoRender();
    }
    
    public function indexAction() {
        $jsUrl = $this->view->baseUrl('public/js/');
        $this->view->headScript()->appendFile($jsUrl . 'jquery-1.4min.js' , 'text/javascript');
        echo "<br>" . __METHOD__;
    }
    
    public function homeAction() {
        echo "<br>" . __METHOD__;
        $this->_helper->layout->disableLayout();
    }
    
    public function contactAction() {
        echo "<br>" . __METHOD__;
        $this->_helper->layout->disableLayout();
    }
    
    public function productAction() {
        echo "<br>" . __METHOD__;
        $this->_helper->layout->disableLayout();
    }
    
    public function aboutAction() {
        echo "<br>" . __METHOD__;
        $this->_helper->layout->disableLayout();
    }
    
    public function cityAction(){
        $jsUrl = $this->view->baseUrl('/public/js'); 
        $this->view->headScript()->appendFile($jsUrl . '/jquery-1.4min.js','text/javascript');
        $db = Zend_Registry::get('connectDb');
        //$db = Zend_Db::factory($a,$b);
        $select = $db->select()
                                 ->from('cities', array('id','name'))
                                 ->where('status = 1')
                                 ->order('order ASC');
        $result = $db->fetchPairs($select);
        array_unshift($result,'--Select an Item---');
        $this->view->slbCity = $result;
    }
	
    public function districtAction(){
        $this->_helper->layout->disableLayout();

        $city_id = $this->_request->getParam('id',0);
        if($city_id > 0){
            $db = Zend_Registry::get('connectDb');
            //$db = Zend_Db::factory($a,$b);
            $select = $db->select()
                                     ->from('districts', array('id','name'))
                                     ->where('status = 1')
                                     ->where('city_id = ?',$city_id,INTEGER)
                                     ->order('order ASC');
            $result = $db->fetchPairs($select);
            $this->view->slbDistrict = $result;
        }
    }
 }
